//
//  UIBarbutton_Category.swift
//  SinaProject
//
//  Created by guochong on 16/4/21.
//  Copyright © 2016年 吴学宇. All rights reserved.
//

import UIKit

extension UIBarButtonItem{
    
  class  func createBarButtonItem(imageName:String?, target:AnyObject?, action : Selector) ->UIBarButtonItem{
    
    let button = UIButton(type: UIButtonType.Custom);
    
    button.setImage(UIImage(named: imageName!), forState: UIControlState.Normal);
    button.addTarget(target, action: action, forControlEvents: UIControlEvents.TouchDragInside);
    button.setImage(UIImage(named: imageName! + "_highlighted"), forState: UIControlState.Selected);
    button.sizeToFit();
    let barItem = UIBarButtonItem(customView: button)
    
    
    return barItem;

        
    }

    
}